n1 = int(input())
arr1 = [int(i) for i in input().split(" ")]
n2 = int(input())
arr2 = [int(i) for i in input().split(" ")]
arr3 = [0] * (n1 + n2)
p1 = 0
p2 = 0
p3 = 0
while p1 < n1 or p2 < n2:
    if p2 >= n2:
        arr3[p3] = arr1[p1]
        p1 += 1
        p3 += 1
    elif p1 >= n2:
        arr3[p3] = arr2[p2]
        p2 += 1
        p3 += 1
    elif arr1[p1] <= arr2[p2]:
        arr3[p3] = arr1[p1]
        p1 += 1
        p3 += 1
    else:
        arr3[p3] = arr2[p2]
        p2 += 1
        p3 += 1
for num in arr3:
    print(num, end=" ")
